package org.blogwu.learn.netty学习.chapter0.bio;

import java.io.*;
import java.net.Socket;

public class Client2 {

    public static void main(String[] args) {
        try (Socket socket = new Socket("127.0.0.1", 9999);
             OutputStream outputStream = socket.getOutputStream();
             BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream));
             InputStream inputStream = socket.getInputStream();
             BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        ) {
            bufferedWriter.write("服务端是个大傻逼");
            bufferedWriter.flush();
            outputStream.flush();
            String str = null;
            System.out.println("注册");
            while ((str = bufferedReader.readLine()) != null) {
                if (str.length() <= 0) {
                    System.out.println("无数据");
                    break;
                }
                System.out.println("服务端传入数据：" + str);
            }
            System.out.println("注册3");

//           String info="";
//           String temp=null;//临时变量
//           while((temp=bufferedReader.readLine())!=null){
//               info+=temp;
//               System.out.println("客户端接收服务端发送信息："+info);
//           }


        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
